<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <script src="resource/jquery214.js"></script>
    <script src="resource/fastclick.js"></script>
    <script src="resource/zeptomin.js"></script>
    <script src="resource/picker.js"></script>
    <script src="../script/api.js"></script>
    <script src="resource/md5.js"></script>
    <script type="text/javascript" src="../script/constants.js"></script>
    <script type="text/javascript" src="../script/aes.js"></script>
    <script type="text/javascript" charset="UTF-8" src="../script/naes.js"></script>
    <script type="text/javascript" src="../script/modeecb.js"></script>
    <script src="../script/tmd5.js"></script>
    <style>
  .odiv{
	   display:table;
	   background:#fff;
	   width:100%;
	   padding:5px;
	   border-top:1px solid #E1E1E1; 
	   border-bottom:1px solid #E1E1E1;
   }
   .idiv{
	   float: left;
	   font-size:15px;
	   margin-left: 10px;
	   height:40px;
	   line-height:40px;
   }
   .div_text{
	   float: right;
	   height:40px;
	   line-height:40px;
	   width:65%;
	   color: #8d8d8d;
	   font-size:15px;
	   text-align: right;
	   overflow:hidden;
	   white-space: nowrap; 
	   text-overflow: ellipsis;
	   margin-right:10px;
   }
   .ipt{
     border:none;
     outline:none;
     width:100%;
     font-size:16px;
   }
   .select {
	    padding-top:5px;
	    padding-bottom:5px;
		border: 0;
		appearance:none;
		background: #fff;
		color: #000;
		outline: medium none;
		width:100%;
		height:100%;
		font-size: 16px;
	}
   
   .userBnos{
        width: 100%;
        background: #fff;
        z-index: 9999;
        position: absolute;
        border:1px solid #ABABAB;
        display: none;
   }
   
   .userBno{
        width:100%;
        padding-left: 30%;
        padding-top: 4px;
        padding-bottom: 4px;
   }
   
   body {
    overflow-x:hidden;
    margin: 0;
   }
   html {
    overflow-x:hidden;
   }
   
label {cursor:pointer;height:40px;}
label i {font-size:18px;font-style:normal;display:inline-block;width:18px;height:18px;text-align:center;line-height:18px;color:#fff;vertical-align:middle;margin:-2px 2px 1px 0px;border:#2489c5 1px solid;}
input[type="checkbox"] {display:none;}
input[type="checkbox"]:checked + i {background:#2489c5;}
input[type="checkbox"]:disabled + i {border-color:#ccc;}
input[type="checkbox"]:checked:disabled + i {background:#ccc;}

    </style>
</head>
<body style="background:url(../../image/bj.png) repeat-x 0;background-size:100%;">
<div style="background:url(../../image/mainbg.png) no-repeat right 0 bottom 0%;">
<div>
       <header id="statusBar">
		<div style="width:100%;display:table;background: #27a8fa;position:fixed;border-bottom:1px solid #EAEAEA;z-index: 9999;height: 50px;" >
			<div style="float:left;width: 20%;height: 50px;line-height: 50px;" tapmode="presshover" onclick="api.closeWin();">
			  <div style="float:left;width: 30%;height: 50px;">
			   <img style="width: 24px;margin-top: 13px;" src="../image/back.png" />
			   </div>
			   <div style="float:left;width: 50%;color: #ffffff;">
			   返回
			   </div>
			</div>
			<div style="float:left;width: 60%;height: 50px;line-height: 50px;text-align: center;font-weight:bold;color: #ffffff;">
			 重置密码
			</div>
		</div>
	 </header>
          <div style="height:50px"></div>
          <input name="md5_passwd" id="md5_passwd" type="hidden" />
          <input name="sm" id="sm" type="hidden" />
          <input name="type" id="type" type="hidden" value="1"/>
          <input id="phone_yz" name="phone" style="display:none" >
          <input  type="hidden" id="root"/>
          
          <div class='odiv'>  
          <div class='idiv'>手机号</div>
          <div class="div_text" style="margin-right:20px;">
          <input  type="text" class="ipt" id="phone" name="phone" placeholder="请输入手机号"/>
          </div>
          </div>
          <div class='odiv'>  
          <div class='idiv'>验证码</div>
          <div class="div_text" style="margin-right:20px;">
          <input  type="text" id="yzmtx" name="yzmtx" style="border:none;outline:none;width:50%;font-size:16px;" id="code" placeholder="请输入验证码"/>
          <input  type="button" style="border:none;outline:none;width:50%;background: #fff;" tapmode="presshover" id="yzmhq" onclick="getYzm(this)" value="获取验证码"/>
          </div> 
          </div>
          <div class='odiv'>  
          <div class='idiv'>新密码</div>
          <div class="div_text" style="margin-right:20px;">
          <input  type="password" id="passwd" name="passwd" class="ipt" placeholder="请输入6-16的数字字母组合密码"/>
          </div> 
          </div>
          
          <div class='odiv'>  
          <div class='idiv' id="bankCard">确认密码</div>
          <div class="div_text" style="margin-right:20px;">
          <input  type="password" id="passwd1" name="passwd1" class="ipt" placeholder="请输入6-16的数字字母组合密码"/>
          </div> 
          </div>
         

           <div style="padding: 20px 0;width:100%;text-align: center;" onclick="zc()"  id="wzc" tapmode="presshover">
			<div style="width:80%;height:35px;background: #27a8fa;margin:0 auto;color:#fff;line-height: 35px;border-radius:5px;">确认修改</div>
		  </div>
</div>
			
</div>	
<script type="text/javascript">
   apiready = function(){
      if(api.systemType == "ios"){
		   document.getElementById("statusBar").style.background = "#298cb4";
		}
      $api.fixStatusBar( $api.dom('header') );
   }
   
    var timer = null;
    var countdown=60;

    function settime(val) {
      if (countdown == 0) {
        val.removeAttribute("disabled");
        val.value="获取验证码";
        countdown = 60;
        $("#yzm").val("");
        window.clearTimeout(timer);
      } else {
        val.setAttribute("disabled", true);
        val.value="重新发送(" + countdown + ")";
        countdown--;
        timer = setTimeout(function() {
          settime(val);
        },1000);

      }

    }

    function getYzm(e){
      var aeskey = api.loadSecureValue({
        sync: true,
        key: 'aeskey'
      });
        if($("#phone").val()!=null||$("#phone").val()!=null){
          var phone = $("#phone").val();
          if(!(/^1[3|4|5|7|8][0-9]\d{4,8}$/.test(phone))){//验证手机号
            alert("输入正确手机号");
            return false;
          }
          settime(e);
           var ip = "0.0.0.0";
//     api.require('ipAddress').getIp(
//	   function(ret, err) {
	        var content = {"phone":phone,"ip":ip,type:"1"};
	        var callback = function(ret, err){
		            //console.log(JSON.stringify(ret));
		            if(ret.flag=="Y"){
			          alert("验证码已发送，请稍候");
			         }else if(ret.flag=="N"){
			            alert("请求验证码过于频繁，请稍后再试！");
			         }else if(ret.flag=="W"){
			            alert("账号不存在！");
			         }else {
			            alert("验证码发送失败，请重试");
			         }
		        }
		    encApiAjax(JSON.stringify(content),url.hqccode,callback);
     //   });
        }else{
          alert("请先输入手机号码")
        }
      }
      
      function sdsr(){
$("#hide").show();
$("#type").val("1");
$("#taxcode").val("");
}
 function test(){
      $("#hide").show();
      $("#type").val("2");

  var FNScanner = api.require('FNScanner');
		FNScanner.openScanner({
		    autorotation: true
		}, function(ret, err) {
			var content = JSON.stringify(ret.content);
            console.info(JSON.stringify(ret));

		    var userid_val = content.split('&')[4];
		      $("#sm").val(userid_val);
		      if(userid_val!=undefined){
		      $("#taxcode").val("已扫描");
		      }
				    console.log(userid_val);
		});

  }

  function validPsw(passwd) {
    var password = passwd
    var num = 0;
    var number = 0 ;
    var letter = 0 ;
    var bigLetter = 0 ;
    var chars = 0 ;

    if (password.search(/[0-9]/) != -1) {
      num += 1;
      number =1;
    }
    if (password.search(/[A-Z]/) != -1) {
      num += 1;
      bigLetter = 1 ;
    }
    if (password.search(/[a-z]/) != -1) {
      num += 1;
      letter = 1 ;
    }
    if (password.search(/[^A-Za-z0-9]/) != -1) {
      num += 1;
      chars = 1 ;
    }
    if (num >= 2 && (password.length >= 6 && password.length <= 16)) {
      return true;
    }else if(password.length < 6 || password.length > 16){

        alert("密码由6-16个字符组成!");
      return false;
    }else if(num == 1){
      if(number==1){
          alert("不能全为数字!");

        return false;
      }
      if(letter==1){
          alert("不能全为字母!");

        return false;
      }
      if(bigLetter==1){
          alert("不能全为字母!");

        return false;
      }
      if(chars==1){
          alert("不能全为字符!");

        return false;
      }

    }
  }

	function back(){

		// api.openWin({
	  //       name: '回到上一页',
	  //       url: './login.html'
    //     });
    api.closeWin();
	}

  function check0(){
   var phone = document.getElementById("phone").value;

// var email = document.getElementById("email").value;
// var taxcode = document.getElementById("taxcode").value;
   var passwd = document.getElementById("passwd").value;
//
   var passwd1 = document.getElementById("passwd1").value;

    //var yzm = document.getElementById("yzm").value;
    var yzmtx = document.getElementById("yzmtx").value;
    var type = document.getElementById("type").value;
    var sm = document.getElementById("sm").value;
    var phone_yz = document.getElementById("phone_yz").value;


// if( phone_yz != phone ){
//   alert("当前手机号不是获取验证码手机号");
//    $("#wzc").show();
// $("#yzc").hide();
//   return false;
//
// }

if(false==validPsw(passwd)){
   $("#wzc").show();
   $("#yzc").hide();
   return false;
};

    if( passwd != passwd1 ){
      alert("两次输入密码不同");
       $("#wzc").show();
       $("#yzc").hide();
      return false;

    }
    if(yzmtx==null||yzmtx==""){
      // alert("验证码不能为空");
      api.alert({
          title: '信息注册',
          msg: '验证码不能为空',
      });
       $("#wzc").show();
    $("#yzc").hide();
      return false;
    }

    if(!(/^1[3|4|5|7|8][0-9]\d{4,8}$/.test(phone))){//验证手机号
      // alert("输入正确手机号");
      api.alert({
          title: '信息注册',
          msg: '输入正确手机号',
      });
 $("#wzc").show();
    $("#yzc").hide();
      return false;
    }

     document.getElementById("md5_passwd").value = passwd ;
    /* if(document.getElementById("addrid").value==null||document.getElementById("addrid").value==""){
     alert("请选择地址");
     return false;
     }*/
     $("#wzc").show();
    $("#yzc").hide();
    return true;
  }


  function zc() {

  	  var phone = document.getElementById("phone").value;
      var passwd = document.getElementById("passwd").value;
	  var passwd = md5(passwd);
	  document.getElementById("md5_passwd").value = passwd ;
	  var md5_passwd = document.getElementById("md5_passwd").value;
      var yzmtx = document.getElementById("yzmtx").value;

    var a = check0();
    var _openid = api.deviceId;
    if(_openid =='02:00:00:00:00:00' || _openid == '' || _openid == null){
      _openid = phone;
    }
    $api.setStorage('openid',_openid);
    $api.setStorage('dl_phone',phone);
    if(a){
    $("#wzc").hide();
    $("#yzc").show();
      var aeskey = api.loadSecureValue({
	    sync: true,
	    key: 'aeskey'
	  });
	  var salt = api.loadSecureValue({
	       sync: true,
	       key: 'salt'
	  });
	  var content = {"openid":_openid,"phone":phone,"md5_passwd":md5_passwd,"yzm":yzmtx};
      var callback = function(ret, err){
            //console.log(JSON.stringify(ret));
            if (ret.flag=="Y") {
                api.alert({msg:'重置成功'});
                api.closeToWin({
	                name: 'root'
                });
       		 }else if(ret.flag=="D"){
             api.alert({msg:'验证码错误'});
        		 	$("#yzc").hide();
                 $("#wzc").show();
             }else{
       		 	api.alert({msg:'重置失败'});
       		 	$("#yzc").hide();
                $("#wzc").show();
       		 }
      }
      encApiAjax(JSON.stringify(content),url.updatemm,callback);
    }
  }
var sj ='0';
</script>	
</body>
</html>